<?php
/**
 *UserController
 * @author tan bing
 * @date 2021-08-11 11:57
 */


namespace Modules\User\Http\Controllers\Api;


use Modules\User\Services\Api\UserServices;

class UserController extends ApiBaseController
{

    /**
     * @var UserServices
     * @author tan bing
     */
    private $userServices;

    /**
     * UserController constructor.
     *
     * @param UserServices $userServices
     * @author tan bing
     * @date 2021-08-11 12:37
     */
    public function __construct(UserServices $userServices)
    {
        $this->userServices = $userServices;
    }

    /**
     * @return mixed
     * @author tan bing
     * @date 2021-08-11 12:37
     */
    public function info()
    {
        $result = $this->userServices->info();

        return $this->success($result);
    }

    /**
     * 收藏列表
     * @author renjianhong
     * @date 2021-10-9 17:02
     */
    public function favoriteList()
    {
        $result = $this->userServices->getFavoriteList();
        return $this->success($result);
    }

    /**
     * 绑定父级ID
     * @return mixed
     * @throws \Throwable
     * @author tan bing
     * @date 2021-11-09 17:39
     */
    public function bindParentId()
    {
        try {
            $result = $this->userServices->bindParentId();
        } catch (\Exception $e) {
            return $this->failed($e->getMessage());
        }

        return $this->success($result);
    }
}